<template>
  <div>
    <ul>
      <!-- 方式一：字符串形式 -->
      <!-- <li v-for="message in messageList" :key="message.id">
        <router-link
          :to="`/home/messages/details/:${message.id}/:${message.title}`"
          >{{ message.title }}</router-link
        >&nbsp;&nbsp;
      </li> -->
      <!-- 方式二：对象形式 -->
      <li v-for="message in messageList" :key="message.id">
        <!-- 传递params参数时，to的对象写法只能用name，不能用path！！ -->
        <router-link :to="{ name: 'details', params: { id: message.id, title: message.title } }">{{
          message.title
        }}</router-link>
      </li>
    </ul>
    <hr />
    <router-view></router-view>
  </div>
</template>

<script>
import { v4 as uuidv4 } from "uuid";

export default {
  name: "Messages",
  data() {
    return {
      messageList: [
        { id: uuidv4(), title: "message001" },
        { id: uuidv4(), title: "message002" },
        { id: uuidv4(), title: "message003" },
      ],
    };
  },
};
</script>

<style>
</style>